﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TTDataAccess;
using TTEntity;
using System.Data;

namespace TTBusiness
{
    public class clsBSImage
    {
        clsDAImage objDA = new clsDAImage();
        private clsImage getDataFromRow(DataRow dr)
        {
            try
            {
                clsImage obj = new clsImage();
                if (!dr.Equals(null))
                {
                    if (!dr.IsNull("ID"))
                        obj.Id = Convert.ToInt32(dr["ID"]);
                    if (!dr.IsNull("Name"))
                        obj.Name = dr["Name"].ToString();
                    if (!dr.IsNull("Link"))
                        obj.Link = dr["Link"].ToString();
                    if (!dr.IsNull("TypeID"))
                        obj.TypeId = Convert.ToInt32(dr["TypeID"]);
                }
                return obj;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsImage> getAll()
        {
            try
            {

                List<clsImage> objList = new List<clsImage>();
                DataTable dt = new DataTable();
                dt = objDA.GetAll();
                foreach (DataRow dr in dt.Rows)
                {
                    clsImage account = new clsImage();
                    account = getDataFromRow(dr);
                    objList.Add(account);
                }
                return objList;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Insert(clsImage obj)
        {
            try
            {
                objDA.Insert(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Update(clsImage obj)
        {
            try
            {
                objDA.Update(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Delete(int id)
        {
            try
            {
                objDA.Delete(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
